package com.jeethink.erp.pileDetail.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jeethink.common.annotation.Log;
import com.jeethink.common.core.controller.BaseController;
import com.jeethink.common.core.domain.AjaxResult;
import com.jeethink.common.enums.BusinessType;
import com.jeethink.erp.pileDetail.domain.TbStockPileDetail;
import com.jeethink.erp.pileDetail.service.ITbStockPileDetailService;
import com.jeethink.common.utils.poi.ExcelUtil;
import com.jeethink.common.core.page.TableDataInfo;

/**
 * 库存流水明细Controller
 * 
 * @author ypr
 * @date 2021-05-28
 */
@RestController
@RequestMapping("/erp/pileDetail")
public class TbStockPileDetailController extends BaseController
{
    @Autowired
    private ITbStockPileDetailService tbStockPileDetailService;

    /**
     * 查询库存流水明细列表
     */
    @PreAuthorize("@ss.hasPermi('erp:pileDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbStockPileDetail tbStockPileDetail)
    {
        startPage();
        List<TbStockPileDetail> list = tbStockPileDetailService.selectTbStockPileDetailList(tbStockPileDetail);
        return getDataTable(list);
    }

    /**
     * 导出库存流水明细列表
     */
    @PreAuthorize("@ss.hasPermi('erp:pileDetail:export')")
    @Log(title = "库存流水明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbStockPileDetail tbStockPileDetail)
    {
        List<TbStockPileDetail> list = tbStockPileDetailService.selectTbStockPileDetailList(tbStockPileDetail);
        ExcelUtil<TbStockPileDetail> util = new ExcelUtil<TbStockPileDetail>(TbStockPileDetail.class);
        return util.exportExcel(list, "pileDetail");
    }

    /**
     * 获取库存流水明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:pileDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbStockPileDetailService.selectTbStockPileDetailById(id));
    }

    /**
     * 新增库存流水明细
     */
    @PreAuthorize("@ss.hasPermi('erp:pileDetail:add')")
    @Log(title = "库存流水明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbStockPileDetail tbStockPileDetail)
    {
        return toAjax(tbStockPileDetailService.insertTbStockPileDetail(tbStockPileDetail));
    }

    /**
     * 修改库存流水明细
     */
    @PreAuthorize("@ss.hasPermi('erp:pileDetail:edit')")
    @Log(title = "库存流水明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbStockPileDetail tbStockPileDetail)
    {
        return toAjax(tbStockPileDetailService.updateTbStockPileDetail(tbStockPileDetail));
    }

    /**
     * 删除库存流水明细
     */
    @PreAuthorize("@ss.hasPermi('erp:pileDetail:remove')")
    @Log(title = "库存流水明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbStockPileDetailService.deleteTbStockPileDetailByIds(ids));
    }
}
